package com.ccb.jyzx.expand.tiantouonline.utils;

/**
 * @author XIEFEI
 * @date 2019-06-20 10:25
 * @Description 文件上传工具
 **/
public class FileUploadUtils {
    public synchronized static byte[] hexToByte(String str) {
        try {
            byte[] bytes = new byte[str.length() / 2];
            for(int i = 0; i < str.length() / 2; i++) {
                String subStr = str.substring(i * 2, i * 2 + 2);
                bytes[i] = (byte) Integer.parseInt(subStr, 16);
            }
            return bytes;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    public synchronized static String hexToStr(String hex){
        try {
            StringBuilder sb = new StringBuilder();
            String[] split = hex.split(",");
            for (String str : split) {
                int i = Integer.parseInt(str, 16);
                sb.append((char)i);
            }
            return sb.toString();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }

    }


}
